

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_getx_cms/pages/home/view.dart';
import 'package:flutter_getx_cms/pages/login/view.dart';
import 'package:flutter_getx_cms/pages/main_page.dart';
import 'package:flutter_getx_cms/pages/splash/view.dart';
import 'package:flutter_getx_cms/pages/workbench/view.dart';
import 'package:flutter_getx_cms/utils/locale_controller.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get_navigation/src/root/get_material_app.dart';
import 'package:get/get_navigation/src/routes/get_route.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

import 'components/webview_flutter/webview_container.dart';
import 'lang/translation_service.dart';

class MyApp extends StatelessWidget {
  const MyApp({super.key,required this.themeJSON});

  final String themeJSON;

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
        builder:()=> GetMaterialApp(
          title: 'CMS',
          theme: ThemeData(
            extensions: [TDThemeData.fromJson('blue', themeJSON)!],
          ),
          initialRoute: '/splash',
          getPages: [
            GetPage(name: '/splash', page: () => GetSplashPage()),
            GetPage(name: '/webview', page: () => WebviewContainerPage()),
            GetPage(name: '/login', page: () => GetLoginPage()),
            GetPage(name: '/main', page: () => GetMainPage()),
            GetPage(name: '/home', page: () => GetHomePage()),
            GetPage(name: '/workbench', page: () => GetWorkbenchPage()),
          ],
          // 添加本地化代理
          localizationsDelegates: const [
            GlobalMaterialLocalizations.delegate,
            GlobalWidgetsLocalizations.delegate,
            GlobalCupertinoLocalizations.delegate,
          ],
          supportedLocales: LocaleController.supportLocaleList(),
          locale: LocaleController.defaultLanguage(), // 默认语言
          translations: TranslationService(), // 加载翻译
          builder: FlutterSmartDialog.init(),
          // home: GetHomePage(),
        )
    );






  }
}
